package service;

import java.util.List;

import dao.MovieDao;
import dao.MovieDaoImpl;
import entity.Cinema;
import entity.Movie;

public class ServiceMovieImpl implements ServiceMovie{

	@Override
	public List<Movie> MovieAll() {
		MovieDao moviedao = new MovieDaoImpl();
		
		List<Movie> movieList = moviedao.MovieAll();
		for(Movie m:movieList){
			String director = m.getDirector();
			if(director.length()>10){
				String director_short = director.substring(0, 10);
				m.setDirector(director_short+"...");
			}
			String mainActor = m.getMainActor();
			if(mainActor.length()>11){
				String mainActor_short = mainActor.substring(0, 11);
				m.setMainActor(mainActor_short+"...");
			}
			
			
		}
		return movieList;
	}

	@Override
	public List<Cinema> CinemaAll() {
		MovieDao moviedao = new MovieDaoImpl();
		List<Cinema> cinemaList = moviedao.CinemaAll();
		return cinemaList;
	}

	@Override
	public List<Movie> StatusAll() {
		MovieDao moviedao = new MovieDaoImpl();
		List<Movie> jjsyList = moviedao.StatusAll();
		for(Movie m:jjsyList){
			String director = m.getDirector();
			if(director.length()>10){
				String director_short = director.substring(0, 10);
				m.setDirector(director_short+"...");
			}
			String mainActor = m.getMainActor();
			if(mainActor.length()>11){
				String mainActor_short = mainActor.substring(0, 11);
				m.setMainActor(mainActor_short+"...");
			}
		}
		return jjsyList;
	}

	@Override
	public List<Movie> Status1All() {
		MovieDao moviedao = new MovieDaoImpl();
		List<Movie> zzryList = moviedao.Status1All();
		for(Movie m:zzryList){
			String director = m.getDirector();
			if(director.length()>10){
				String director_short = director.substring(0, 10);
				m.setDirector(director_short+"...");
			}
			String mainActor = m.getMainActor();
			if(mainActor.length()>11){
				String mainActor_short = mainActor.substring(0, 11);
				m.setMainActor(mainActor_short+"...");
			}
		}
		return zzryList;
	}

}
